﻿using System;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace YArchitech.Revit.MEP.Opening
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdWorkSet : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string messages, ElementSet elements)
		{
			Document document = cmdData.Application.ActiveUIDocument.Document;
			MessageBox.Show(this.GetActiveWorkset(document).Owner);
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		public Workset GetActiveWorkset(Autodesk.Revit.DB.Document doc)
		{
			WorksetTable worksetTable = doc.GetWorksetTable();
			WorksetId activeWorksetId = worksetTable.GetActiveWorksetId();
			return worksetTable.GetWorkset(activeWorksetId);
		}
	}
}
